package edu.gdkm.sql.dao;

import edu.gdkm.sql.pojo.Order;
import edu.gdkm.sql.pojo.Product;
import edu.gdkm.sql.pojo.Productdetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductdetailMapper {



    // 查询全部类别
    @Select("select * from productdetail")
    List<Productdetail> findAll();
    // 根据id查询类别
    @Select("SELECT * FROM productdetail WHERE id = #{id}")
    Productdetail findById(int id);

    @Insert("INSERT INTO productdetail(goodspicurl,goodsdes,stock,brand,productid) VALUES" +
            "(#{goodspicurl},#{goodsdes},#{stock},#{brand},#{productid})")
    int insertProductdetail(Productdetail productdetail);

    // 更新类别
    @Update("UPDATE order SET goodspicurl=#{goodspicurl},goodsdes=#{goodsdes},stock=#{stock},brand=#{brand},productid=#{productid} WHERE id=#{id}")
    int updateProductdetailById(Productdetail productdetail);

    // 删除类别
    @Delete("DELETE FROM productdetail WHERE id=#{id}")
    int deleteProductdetailById(int id);

    @Select("SELECT * FROM productdetail WHERE productid = #{productid}")
    Productdetail findProductById();


}
